#include <signal.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <errno.h>

void handler(int signo) {
	if (signo == SIGUSR1 ) {
		printf("receive SIGUSR1\n");
		// ps -aux | grep ./a.out
		// kill -USR1 pid
	} else if (signo = SIGUSR2) { // kill -USR2 pid
		printf("receive SIGUSR2\n");
	} else if (signo = SIGINT) { // ctrl + c
		printf("receive SIGINT\n");
	}
}

int main(void) {
	struct sigaction sa_usr;
	sa_usr.sa_handler = handler;
	sigemptyset(&sa_usr.sa_mask)
	sa_usr.sa_flags = 0;

	if (sigaction(SIGINT, &sa_usr, NULL) < 0) {
		printf("sigaction SIGINT fail\n");
		return SIG_ERR;
	}
	sigaction(SIGUSR1, &sa_usr, NULL);
	sigaction(SIGUSR2, &sa_usr, NULL);

	printf("my pid is %d\n", getpid());

	while (1) {
		sleep(10);
	}
	return 0;
}